package com.buddy.learn.javasource._lambda;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Buddy
 * @date 2021/5/13
 */
public class _StreamFilter {

    public static void main(String[] args) {
        // Filter: 为过滤的意思，只要满足 Filter 表达式的数据就可以留下来，不满足的数据被过滤掉
        List<String> list = new ArrayList<>(Arrays.asList("Hello", "Stream", "Java", null));
        List<String> newList = list.stream()
                .filter(str -> str != null && str.equalsIgnoreCase("hello"))
                .collect(Collectors.toList());
        System.out.println(JSON.toJSONString(newList));



    }
}
